
import { getData, postData, postDataJson,postFormData } from '@/api/requestData'

// ----------- 登录注册模块 -----------
// 登录
export function login(params) {
  return postData('/plat/form/login', params)
}
// 注册
// reg
export function register(params) {
  return postData('/reg', params)
}

// ----------- pipeline模块 -----------
// 获取pipeline列表
export function getPipelineList(params) {
  return getData('/pipeline/list', params)
}
// 获取pipeline详情
export function getPipelineDetail(params) {
  return getData(`/pipeline/detail/${params}`)
}
// 获取镜像列表
export function getPublicLanguageList(params) {
  return getData('/pipeline/public/language/list', params);
}
// 获取仓库地址
export function getGitPublicList(params) {
  return getData('/git/public/list', params);
}
// 获取分支列表
export function getGitPublicBranches(gitId, params) {
  return getData(`/git/public/branches/${gitId}`, params);
}
// 获取第三方分支列表
export function getCustomBranches(params) {
  return postData('/git/public/custom/branches', params);
}
// 获取默认流水列表
export function getPublicFlowTemplate(params) {
  return getData('/pipeline/public/flow/template', params);
}
// 创建pipeline
export function pipelineCreate(params) {
  return postDataJson('/pipeline/create', params);
}
// 更新pipeline
export function pipelineUpdate(params) {
  return postDataJson('/pipeline/update', params);
}
// 清理pipeline
export function pipelineClean(params) {
  return postData(`/pipeline/clean/${params}`);
}
// 删除pipeline
export function pipelineDelete(params) {
  return postData(`/pipeline/del/${params}`);
}
// 导出pipeline
export function pipelineExport(params) {
  return getData(`pipeline/export/setting/${params}`);
}
// 获取docker节点模板
export function getPublicDocker(params) {
  return getData('/pipeline/public/docker/file', params);
}
// 保存单个pipeline工作流编辑
export function submitPipeDetail(params) {
  return postDataJson('/pipeline/update/detail', params);
}
// 运行pipeline
export function runPipeList(params) {
  return postData(`/pipeline/run/${params}`);
}
// 停止运行pipeline
export function stopPipeList(params) {
  return postData(`/pipeline/stop/${params}`);
}
// 获取pipeline日志列表
export function getRunLogList(id,params) {
  return getData(`/pipeline/log/list/${id}`, params);
}
// 获取pipeline运行日志
export function runLogPipeList(params) {
  return getData(`/pipeline/log/detail/${params}`);
}
// 获取pipeline文件列表（分页）
export function getPipelineFileList(params) {
  return getData('/pipeline/public/upload/list', params)
}
// 获取pipeline文件列表（无分页）
export function getPipelineFileListAll(params) {
  return getData('/pipeline/public/upload/list/all', params)
}
// pipeline上传文件
export function uploadFilePipeline(params) {
  return postFormData('/pipeline/public/upload', params);
}
// pipeline导入配置文件
export function importSettingFile(params) {
  return postFormData('/pipeline/import/setting', params);
}
// 默认流水线列表
export function getPipeList(params) {
  return getData('/pipeline/flow/list', params)
}
// 删除默认流水线
export function deletePipeList(params) {
  return postData(`/pipeline/flow/del/${params}`)
}
// 获取要触发的pipeline列表
export function getPipelinePublicList(params) {
  return getData('pipeline/public/list', params)
}
// 流水线容器运行状态
export function getPipelineContainerState(params) {
  return getData('/pipeline/public/status/list', params)
}

// ----- git模块 -----

// 获取git仓库列表
export function getGitList(params) {
  return getData('/git/list', params);
}
// 创建代码仓库
export function createRepo(params) {
  return postData('/git/create/repo', params);
}
// 导入代码仓库
export function importRepo(params) {
  return postData('/git/import/repo', params);
}
// 删除git仓库
export function deleteRepo(params) {
  return postData('/git/del/repo', params);
}
// 获取git分支
// /git/public/all/branches/
export function getBranchesList(params) {
  return getData(`/git/public/all/branches/${params}`);
}

// ----- 质量阈 -----
// 创建
export function createQg(params) {
  return postData('/sonar/qg/create', params)
}
// 重命名
export function renameQg(params) {
  return postData('/sonar/qg/rename', params)
}
// 详情
export function getQgDetail(params) {
  return getData('/sonar/qg/show', params)
}
// 删除
export function deleteQg(params) {
  return postData('/sonar/qg/del', params)
}
// 列表
export function getQgList(params) {
  return getData('/sonar/public/qg/user/all', params)
}
// 列表 条件
export function getQgCondiList(params) {
  return getData('/sonar/qg/condition/list', params)
}
// 创建 条件
export function createQgCondi(params) {
  return postData('/sonar/qg/create/condition', params)
}
// 修改 条件
export function updateQgCondi(params) {
  return postData('/sonar/qg/update/condition', params)
}
// 删除 条件
export function deleteQgCondi(params) {
  return postData('/sonar/qg/del/condition', params)
}
// sonar报告
export function getSonarReport(params) {
  return getData('/sonar/project/report', params)
}

// ----- 邮箱设置 -----
// 获取邮箱配置
export function getEmail() {
  return getData('/setting/email')
}

// 更新邮箱配置
export function updateEmail(params) {
  return postData('/setting/email', params)
}

// 邮箱测试
export function testEmail(params) {
  return getData('/setting/test/email', params)
}

// ----- 用户管理 -----
// 获取用户列表
export function getUserList() {
  return getData('/user/public/list')
}

// 设置管理人员
export function setPipelineManageUser(pid, params) {
  return postData(`/pipeline/manage/users/${pid}`, params)
}

// 获取SSH密钥
export function getSshKey() {
  return getData('/setting/public/ssh/key')
}

// ----- Git设置 -----
// 获取git账号信息
export function getGitAccount() {
  return getData('/git/public/repo/account')
}

// 绑定其他git账号
export function setGitAccount(params) {
  return postData('/git/repo/account', params)
}
